/*
 * 
 * PanjatPinangGLES1
 * Utils.java
 * Pratama Wijaya
 * set.mnemonix@gmail.com
 * 11:13:08 PM , Jul 11, 2012
 */
package com.amikomgamedev.panjatpinangGLES1;

import java.util.Random;

public class Utils {

	public static int getRatioW(int def) {
		return (int) ((def / Define.GAME_RATIO_SCREEN_WIDTH) * Define.GAME_RATIO_SCREEN_WIDTH);
	}

	public static int getRatioH(int def) {
		return (int) ((def / Define.GAME_RATIO_SCREEN_HEIGHT) * Define.GAME_RATIO_SCREEN_HEIGHT);
	}

	public static int getRandomValue(int maxValue) {
		return (int) getRandomValue(0, maxValue, new Random());
	}

	public static int getRandomValue(int aStart, int aEnd, Random aRandom) {
		if (aStart > aEnd) {
			throw new IllegalArgumentException("Start cannot exceed End");
		}

		long range = (long) aEnd - (long) aStart + 1;

		long fraction = (long) (range + aRandom.nextDouble());
		int randomNumber = (int) (fraction + aStart);
		return randomNumber;
	}

	public static void TRACE(String args) {
		if (Config.DEBUG) {
			System.out.println(args);
		}
	}

	public static void TRACE(Exception args) {
		if (Config.DEBUG) {
			args.printStackTrace();
		}
	}

}
